Extended Markup Language (XML) is a standard protocol for exchanging data between distributed applications or layers of the same application in a database system. Many of these applications access data by calling database stored procedures residing on a database server in the form of stored procedure output parameters or multiple result sets.
FIG. 1 illustrates a conventional database system. The database system includes an application server 102 and a database server 104. To access data, the application server 102 calls a stored procedure 106 residing on the database server 104. The stored procedure 106 returns data 108 in the form of stored procedure output parameters or multiple result sets. Since the stored procedure 106 does not understand XML, the returned data 108 is typically in some other format, such as the Structure Query Language (SQL) format. Code thus need to be manually generated which converts the SQL data 108 to XML data. The XML data can then be exchanged between application layers or between distributed applications.
However, the manual generation of code is cumbersome and time consuming, particularly when a large number of stored procedures are called. In addition, extra coding is required if the formatting of the XML data is to be optimized.
Accordingly, there exists a need for a method and system for automatically generating code for converting data from stored procedures to an XML format. The method and system should optimize the formatting of the data as well. The present invention addresses such a need.